fix rounding error + atan(0,0) instability
authorparkrrrr <parkrrrr@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Thu, 6 Apr 2006 20:54:33 +0000 (20:54 +0000)
committerparkrrrr <parkrrrr@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Thu, 6 Apr 2006 20:54:33 +0000 (20:54 +0000)
gpsbabel/garmin_txt.c

index 1be486c645c5ce394e155e5d6b96c24e17f3ed64..b6b19fb9e3571faceaff092c2feba1bd5e9d078c 100644 (file)
@@ -296,6 +296,7 @@ course_rad(double lat1, double lon1, double lat2, double lon2)
        v1 = sin(lon1 - lon2) * cos(lat2);
        v2 = cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(lon1 - lon2);
        if (fabs(v2) < 0.000000000000001) v2 = 0.0;     /* fix calculation diff. between 32- and 64-bit systems */
+       if (fabs(v1) < 0.000000000000001) v1 = 0.0;     /* fix calculation diff. between 32- and 64-bit systems */
        return atan2(v1, v2);
 }